package com.example.demo.controller;


import com.example.demo.entity.CityData;
import com.example.demo.model.result;
import com.example.demo.services.CityDataService;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.relational.core.sql.In;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/data")
public class CityDataController {

    @Autowired
    private CityDataService cityDataService;

    private Logger logger= LoggerFactory.getLogger(getClass());

    @RequestMapping(value = "/abroad",method = {RequestMethod.GET})
    public result city(){
        logger.info("用户正在查询所有类型数据");
        return result.success(cityDataService.selectall());
    }

    @RequestMapping(value = "/broad",method = {RequestMethod.GET})
    public result broad(){
        logger.info("用户查询境外患者数");
        return result.success(cityDataService.selectabroad());
    }

    @RequestMapping(value = "/Abroad",method = {RequestMethod.GET})
    public result testabroad(){
        return result.success(cityDataService.selectAbroad());
    }

    @RequestMapping(value = "/territory",method = {RequestMethod.GET})
    public result territory(){
        return result.success(cityDataService.selectterritory());
    }

    @RequestMapping(value = "/datenew",method = {RequestMethod.GET})
    public result selectall(){
        return result.success(cityDataService.selectnew());
    }

    @RequestMapping(value = "/accumulate",method = {RequestMethod.GET})
    public result selectaccumulate(){
        return result.success(cityDataService.selectaccumulate());
    }

    @RequestMapping(value = "/accumulateDie",method = {RequestMethod.GET})
    public result selectaccumulateDie(){
        return result.success(cityDataService.selectaccumulate_die());
    }

    @RequestMapping(value = "/accumulateSure",method = {RequestMethod.GET})
    public result selectaccumulateSure(){
        return result.success(cityDataService.selectaccumulate_sure());
    }

    @RequestMapping(value = "/accumulateVaccines",method = {RequestMethod.GET})
    public result selectaccumulateVaccines(){
        return result.success(cityDataService.selectaccumulate_vaccines());
    }

    //name是哪个城市 sec那一列数据 num现在的数目
    @RequestMapping(value = "/update",method = {RequestMethod.PUT})
    public result updateData(String name, String sec,Integer num){
        return result.success(cityDataService.updateData(name, sec, num));
    }

    @RequestMapping(value = "/allupdate",method = {RequestMethod.PUT})
    public result allupdata(CityData cityData){
        return result.success(cityDataService.allUpdate(cityData));
    }

    @RequestMapping(value = "selectNum",method = {RequestMethod.GET})
    public result selectnum(){
        return result.success(cityDataService.num());
    }



}
